/***
 * 自己书写格式化数据的函数
 * 数值/人民币金额
 */

function formatNumber(val: any) {
  return `${val}`.replace(/(\d{3})(?=\d)/g, "$1,")
}

export function formatData() {
  const numberFormat = (val: any) => formatNumber(val)
  const moneyFormat = (val: any) => `￥${formatNumber(val)}`

  return {
    numberFormat,
    moneyFormat,
  }
}
